{% extends 'base.html' %}

{% block title %}节点{% endblock %}

{% block body %}
<section class="login">
    <h1 class="heading"> <span>节点</span> Node </h1>
    <div class="row">
        <form method="post" novalidate>
            {{ form.csrf_token() }}

            {{ form.ip }}
            {% if form.ip.errors.0 %}
            <div class="error">
                <span>{{ form.ip.errors.0 }}</span>
            </div>
            {% endif %}

            {{ form.area }}
            {% if form.area.errors.0 %}
            <div class="error">
                <span>{{ form.area.errors.0 }}</span>
            </div>
            {% endif %}

            {{ form.security_code }}
            {% if form.security_code.errors.0 %}
            <div class="error">
                <span>{{ form.security_code.errors.0 }}</span>
            </div>
            {% endif %}

            {{ form.server_account }}
            {% if form.server_account.errors.0 %}
            <div class="error">
                <span>{{ form.server_account.errors.0 }}</span>
            </div>
            {% endif %}

            {{ form.server_password }}
            {% if form.server_password.errors.0 %}
            <div class="error">
                <span>{{ form.server_password.errors.0 }}</span>
            </div>
            {% endif %}

            <div class="loginBtn">
                {{ form.submit() }}
            </div>
            {% if tips %}
            <div class="errors">
                <span>{{ tips }}</span>
            </div>
            {% endif %}
        </form>
    </div>
</section>

<section class="idc" id="idc">
    <h1 class="heading"> 快乐云&trade; <span>节点</span> </h1>
    <div class="box-container">
    {% if hosts %}
        {% for host in hosts %}
        <div class="box">

            <div class="node">
                <div class="info">
                    <h3>{{ host.ip }}</h3>
                    <h1>{{ host.area }}</h1>
                    <h1>
                        <form action='http://{{ host.ip }}:3312/admin/index.php?c=session&a=login' method="post" target="_blank">
                            <input type="hidden" name="username" value="{{ host.server_account }}">
                            <input type="hidden" name="passwd" value="{{ host.server_password }}">
                            <button type="submit" class="btn gradient"><i class="fas fa-cloud"></i>host后台登录</button>
                        </form>
                    </h1>
                </div>
                <i class="fas fa-quote-right"></i>
            </div>

            <div class="detail">

                <div class="line">
                    <i class="fas fa-cloud"></i>
                </div>

                <div class="line">
                    <div class="left">
                        <i class="fas fa-server">通信安全码:</i>
                    </div>
                </div>
                <div class="line">
                    <div class="right">
                        <i>{{ host.security_code }}</i>
                    </div>
                </div>
                
                <div class="line">
                    <i class="fas fa-database"></i>
                </div>
                <div class="line">
                    <div class="left">
                        <i class="fas fa-server">后台帐号:</i>
                    </div>
                </div>
                <div class="line">
                    <div class="right">
                        <i>{{ host.server_account }}</i>
                    </div>
                </div>

                <div class="line">
                    <div class="left">
                        <i class="fas fa-server">后台密码:</i>
                    </div>
                </div>
                <div class="line">
                    <div class="right">
                        <i>{{ host.server_password }}</i>
                    </div>
                </div>

                <div class="line">
                    <a href="/host/del/{{ host.id }}" class="btn gradient">
                        <div class="right">
                            <i class="fas fa-trash-alt"></i>删除
                        </div>
                    </a>
                </div>
                
            </div>
            {% if host_tips %}
            <div class="errors">
                <span>{{ host_tips }}</span>
            </div>
            {% endif %}
        </div>
        {% endfor %}
    {% endif %}
    </div>
</section>

{% endblock %}

{% block footer %}
{{ super() }}
{% endblock %}
